import tourist from '../src/data/service/index.json';
import servicerLog from '../src/data/service/servicerLog.json';
import chat from '../src/data/service/chat.json';
import fang_house from '../src/data/service/fang_house.json';
import fang_house_sand from '../src/data/service/fang_house_sand.json';
import fang_second_house from '../src/data/service/fang_second_house.json';
import fang_office_rental from '../src/data/service/fang_office_rental.json';
import fang_office from '../src/data/service/fang_office.json';
import fang_rental from '../src/data/service/fang_rental.json';
import fang_shops_rental from '../src/data/service/fang_shops_rental.json';
export default {
  //派发接口数据
  'GET /getTourist': tourist,
  //服务记录
  'GET /servicerLog': (req: any, res: any) => {
    const { search } = req.query;
    if (search) {
      const arr = servicerLog.data.filter((item: any) => {
        return item.kefu_name.includes(search);
      });

      res.send(arr);
    } else {
      res.send(servicerLog.data);
    }
  },
  //聊天记录
  'GET /chat': (req: any, res: any) => {
    const { search } = req.query;

    if (search) {
      const arr = chat.data.filter((item: any) => {
        return item.to_name.includes(search);
      });
      res.send(arr);
    } else {
      res.send(chat.data);
    }
  },
  //楼盘数据
  'GET /fang_house': (req: any, res: any) => {
    res.send(fang_house);
  },
  'GET /fang_houseDetail': (req: any, res: any) => {
    let { id } = req.query;
    let obj = fang_house.RECORDS.find((item: any) => item.id == id);
    // console.log('====================================');
    // console.log(obj);
    // console.log('====================================');
    res.send(obj);
  },
  //获取楼栋列表
  'GET /fang_house_sand': fang_house_sand,
  //二手房 //房源管理
  'GET /fang_second_house': fang_second_house,

  //商场 //写字楼
  'GET /fang_office': fang_office,
  'GET /fang_office_rental': fang_office_rental,
  //商场 // 商铺
  'GET /fang_rental': fang_rental,
  'GET /fang_shops_rental': fang_shops_rental,
};
